package com.sdy.mq.service.impl;

import com.sdy.mq.service.MqSender;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.MQProducer;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DefaultMqSender implements MqSender {
    @Autowired
    private MQProducer mqProducer;
    
    @Override
    public SendResult send(Message message) throws InterruptedException, RemotingException, MQClientException, MQBrokerException {
        return mqProducer.send(message);
    }

    @Override
    public void send(Message message, SendCallback sendCallback) throws RemotingException, MQClientException, InterruptedException {
        mqProducer.send(message, sendCallback);
    }
}
